﻿/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.    
*/

namespace NVelocity.Tests
{
    using NUnit.Framework;

    /// <summary> This class tests support for string concatenation.</summary>
    [TestFixture]
    public class StringConcatenationTestCase : BaseEvalTestCase
    {
        [SetUp]
        public void setUp()
        {
            base.setUp();
            context.Put("foo", "foo");
            context.Put("baz", "baz");
        }

        [Test]
        public virtual void testStringRefLeft()
        {
            assertEvalEquals("foobar", "#set( $o = $foo + 'bar' )$o");
            assertEvalEquals("foo$bar", "#set( $o = $foo + $bar )$o");
            assertEvalEquals("foo1", "#set( $o = $foo + 1 )$o");
            assertEvalEquals("foobaz", "#set( $o = $foo + $baz )$o");
        }

        [Test]
        public virtual void testStringRefRight()
        {
            assertEvalEquals("barfoo", "#set( $o = 'bar' + $foo )$o");
            assertEvalEquals("$barfoo", "#set( $o = $bar + $foo )$o");
            assertEvalEquals("1foo", "#set( $o = 1 + $foo )$o");
        }

        [Test]
        public virtual void testNoRef()
        {
            assertEvalEquals("bar1", "#set( $o = 'bar' + 1 )$o");
        }

        [Test]
        public virtual void testAll()
        {
            assertEvalEquals("foobar$bar1baz", "#set( $o = $foo + 'bar' + $bar + 1 + $baz )$o");
        }
    }
}
